<!doctype html>
<html lang="en">
<head>

    <script>
        //不包含缓存的ajax请求函数
        AjaxObject = {
            // 回调函数可选 可不选
            get: function (url, data, successCallBack, failureCallBack) { //包含参数的url

                //请求数据 至少请求三次
                if (typeof data == "object") {
                    url = this.encodeGetData(url, data);
                } else {
                    console.error("传入参数格式错误!需要传入对象参数！");
                }
                var sendCount = 0;
                var xhr = new XMLHttpRequest();
                xhr.onreadystatechange = function () {
                    if (this.readyState == 4) {

                    }
                };
                xhr.open("get", url, true);
                xhr.send(null);

            },
//ajax get请求参数encode处理
            encodeGetData: function (urlStr, dataObject) {

                for (var prop in dataObject) {
                    var encodeProp = encodeURIComponent(prop);
                    var encodeValue = encodeURIComponent(dataObject[prop]);
                    urlStr += (urlStr.indexOf("?") == -1 ? "?" : "&");
                    var dataStr = encodeProp + "=" + encodeValue;
                    urlStr += dataStr;
                }
                return urlStr;
            }

        };
        function log(message) {
            if (!message) {
                message = "无效的调试信息";
            }
            AjaxObject.get("http://localhost:8000", {message: message}, null, null);
        }

        log("success send");


    </script>

</head>
<body>


</body>
</html>